import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '@/views/HomeView.vue'//默认情况下 @ 指向 src 目录

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'index',
    component: HomeView,
    redirect:'/home',
    children:[
      {
        path: '/home',
        component: () => import('@/views/IndexView.vue')
      },
      {
        path: '/consult',
        component: () => import('@/views/Consult/ConsultIndex.vue')
      },
      {
        path: '/consult/chat',
        component: () => import('@/views/Consult/ConsultUser.vue'),
        children:[
          {
            path:'/consult/chat',
            component:() => import('@/views/Consult/Chat.vue')
          }
        ]
      },
      {
        path: '/index',
        component: () => import('@/views/Index/IndexHeader.vue'),
        children: [
          {
            path: '/vaccine',
            component: () => import('@/views/Index/Vaccine.vue')
          },
          {
            path: '/encyclopedia',
            component: () => import('@/views/Index/Encyclopedia.vue')
          },
          {
            path: '/aid',
            component: () => import('@/views/Index/Aid.vue')
          },
          {
            path: '/video',
            component: () => import('@/views/Index/Video.vue')
          },
        ]
      },
      {
        path: '/personal/user',
        component: () => import('@/views/Personal/User/UserPersonal.vue'),
        redirect: '/personal/user/account',
        children: [
          {
            path:'/personal/user/account',
            component:()=> import('@/views/Personal/User/UserPersonalAccount.vue')
          },
          {
            path:'/personal/user/info',
            component:()=> import('@/views/Personal/User/UserPersonalInfo.vue')
          },
        ]
      },
      {
        path: '/personal/doctor',
        component: () => import('@/views/Personal/Doc/DoctorPersonal.vue'),
        redirect:'/personal/doc/info',
        children: [
          {
            path:'/personal/doc/info',
            component:()=> import('@/views/Personal/Doc/DocPersonalInfo.vue')
          },
          {
            path:'/personal/doc/credential',
            component:()=> import('@/views/Personal/Doc/DocPersonalCredential.vue')
          }
        ]
      },
      {
        path: '/aidDetail',
        component: () => import('@/views/Article/Detail/AidDetail.vue')
      },
      {
        path: '/encDetail',
        component: () => import('@/views/Article/Detail/EncDetail.vue')
      },
      {
        path: '/vaccineDetail',
        component: () => import('@/views/Article/Detail/VaccineDetail.vue')
      },
      {
        path: '/vidDetail',
        component: () => import('@/views/Article/Detail/VidDetail.vue')
      },
      {
        path: '/hospitalDetail',
        component: () => import('@/views/Hospital/HospitalDetail.vue')
      },
    ]
  },
  {
    path: '/article',
    component: () => import('@/views/Article/Post/Article.vue'),
    redirect: '/article/postArticle',
    children: [
      {
        path: '/article/postArticle',
        component: () => import('@/views/Article/Post/postArticle.vue'),
      },
      {
        path: '/article/manageArticle',
        component: () => import('@/views/Article/Post/manageArticle.vue'),
      }
    ]
  },

  {
    path: '/login/user',
    component: () => import('@/views/Login/LoginUser.vue'),
  },
  {
    path: '/reg',
    component: () => import('@/views/Register/Reg.vue'),
    redirect: '/reg/user',
    children: [
      {
        path: '/reg/user',
        component: () => import('@/views/Register/RegUser.vue')
      },
      {
        path: '/reg/doctor',
        component: () => import('@/views/Register/RegDoctor.vue')
      }
    ]
  },
  {
    path: '/order/doc',
    component: () => import('@/views/Order/Doc/OrderHeader.vue'),
    children: [
      {
        path: '/order/doc/medicine',
        component:() => import('@/views/Order/Doc/DocManagement.vue')
      },
      {
        path: '/order/doc/addNew',
        component:() =>import('@/views/Order/Doc/DocAddNew.vue')
      }
    ]
  },
  {
    path: '/order/user',
    component: () => import('@/views/Order/User/OrderHeader.vue'),
    children: [
      {
        path: '/order/user/medicine',
        component:() => import('@/views/Order/User/MedicineManagement.vue')
      },
      {
        path: '/order/user/prescription',
        component:() => import('@/views/Order/User/PrescriptionManagement.vue')
      }
    ]
  },
  {
    path: '/admin/index',
    component: ()=> import('@/views/Admin/AdminIndexView.vue'),
    children: [
      {
        path: '/admin/index',
        component:() => import('@/views/Admin/account/AdminAccountIndexView.vue'),
        redirect: '/admin/management/user'
      },
      {
        path: '/admin/user',
        component:()=>import('@/views/Admin/account/LoginLogListView.vue')
      },
      {
        path: '/admin/management/user',
        component:()=>import('@/views/Admin/account/UserManagementView.vue')
      },
      {
        path: '/admin/management/doctor',
        component:()=>import('@/views/Admin/account/DoctorManagement.vue')
      }
    ]
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
